package naga.x.platform2.channel.weixin.support;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import com.alibaba.fastjson.JSON;

import naga.x.platform2.App;

@Configuration
@EnableAutoConfiguration
@ConfigurationProperties(locations = "classpath:weixin.properties")
public class WeiXinConfig implements InitializingBean {

	private String appId;
	private String mchId; // 商户号
	private String key; // 商户支付秘钥
	private String appSec; // 公众号secret
	private String domain;
	private String clientHost;

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getMchId() {
		return mchId;
	}

	public void setMchId(String mchId) {
		this.mchId = mchId;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getAppSec() {
		return appSec;
	}

	public void setAppSec(String appSec) {
		this.appSec = appSec;
	}

	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}

	public String getClientHost() {
		return clientHost;
	}

	public void setClientHost(String clientHost) {
		this.clientHost = clientHost;
	}

	@Override
	public String toString() {
		return "[appId=" + appId + ", mchId=" + mchId + ", key=" + key + ", appSec=" + appSec + ", domain="
				+ domain + ", clientHost=" + clientHost + "]";
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		WeiXinApi.init(this);
		App.LOG.info("[WEIXIN CONFIG LOADED]{}", this);
	}
	

}
